#include"List.h"

//Creat List
Node* CreatL(const int &len)
{
	Node* head = new(Node);
	Node* p = head;

	for (int i = 1; i <= len; i++)
	{
		p->next = new(Node);
		p = p->next;
		//p->data = i;
	}
	return head;
}

//Write List
void WriteL(int &pos, Person &indata, Node* head)
{
	Node* temp = FindNP(pos, head);
	temp->data = indata;
}

//Find Node by position
Node* FindNP(int &pos, Node* head)
{
	int cnt = 1;
	Node* temp = head->next;
	while (temp->next)
	{
		if (pos == cnt) break;
		temp = temp->next;
		cnt++;
	}
	return temp;
}

//Read List
void ReadL(Node* head)
{
	Node* temp = head->next;
	while (temp)
	{
		cout << temp->data.name << temp->data.weight << endl;
		temp = temp->next;
	}
}